# -*- coding: utf-8 -*-
import thread
import time
from BaseDonnees import *
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler


class Serveur(object):
    def __init__(self):                          #10.57.70.69,11501
        self.server= SimpleXMLRPCServer(("localhost", 8000),allow_none=True,\
                                            requestHandler=SimpleXMLRPCRequestHandler)
        self.server.register_introspection_functions()
        self.BaseDonnees = CommunicationBaseDonnees()
        Message = self.BaseDonnees.DemarrerConnection("b52equip1", "var2", "titan")
        print Message
        if Message[0] == 1:
            self.EnregistrerFonction(self.BaseDonnees)
            self.Demarrer()
        
    def EnregistrerFonction(self,Classe):
        self.server.register_instance(Classe)
    
    def Demarrer(self):
        print 'OK, serveur demarre a '+time.ctime(time.time())
        self.server.serve_forever()
    
    
serveur=Serveur()
